From 6bbf401cbde5414c0e5fef53c3725df7c4aced73 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Sun, 17 Apr 2011 17:22:12 +0100 Subject: [PATCH] stats: remove false negatives from HTML stats output too many of the conversions are flagged as bad in the matrix change code so that only conversions that contribute to more than 0.1% of the overall pixels converted by babl are shown in the stats written when BABL_STATS environment variable is set. --- babl/babl-fish-stats.c | 46 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/babl/babl-fish-stats.c b/babl/babl-fish-stats.c index 7b853b1..f5b3e2a 100644 --- a/babl/babl-fish-stats.c +++ b/babl/babl-fish-stats.c @@ -29,6 +29,41 @@ static char *utf8_bar[]={"·", "█", "▇", "▆", "▅", "▄", "▃", "▂", static char *utf8_bar[]={" ","1","2","3","4","5","6","7","8"}; */ +static double sum_pixels = 0.0; + +static int +table_destination_sum_each (Babl *babl, + void *userdata) +{ + Babl *source = userdata; + Babl *destination = babl; + + if (source != destination) + { + Babl *fish = babl_fish (source, destination); + babl_assert (fish); + sum_pixels += fish->fish.pixels; + } + return 0; +} + +static int +table_source_sum_each (Babl *babl, + void *userdata) +{ + babl_format_class_for_each (table_destination_sum_each, babl); + return 0; +} + +static void +table_sum_processings_calc (void) +{ + sum_pixels = 0; + babl_format_class_for_each (table_source_sum_each, NULL); +} + +#define LIMIT 0.001 + static int table_destination_each (Babl *babl, void *userdata) @@ -51,7 +86,7 @@ table_destination_each (Babl *babl, case BABL_FISH_PATH: fprintf (output_file, "%s", - fish->fish.processings > 0 ? " style='background-color: #69f'" : "", + fish->fish.pixels / sum_pixels > LIMIT ? " style='background-color: #69f'" : "", utf8_bar[babl_list_size (fish->fish_path.conversion_list)]); { @@ -95,11 +130,11 @@ table_destination_each (Babl *babl, case BABL_FISH_REFERENCE: fprintf (output_file, " ", - fish->fish.processings > 0 ? " style='background-color: #f99'" : ""); + fish->fish.pixels / sum_pixels > LIMIT ? " style='background-color: #f99'" : ""); fprintf (output_file, "
"); fprintf (output_file, "

Reference %s to %s

", source->instance.name, destination->instance.name); - if (fish->fish.processings > 0) + if (fish->fish.processings > 1) { fprintf (output_file, "Processings:%i
", fish->fish.processings); fprintf (output_file, "Pixels:%li
", fish->fish.pixels); @@ -110,7 +145,7 @@ table_destination_each (Babl *babl, case BABL_FISH_SIMPLE: fprintf (output_file, "
·", - fish->fish.processings > 1 ? " style='background-color: #69f'" : ""); + fish->fish.pixels / sum_pixels > LIMIT ? " style='background-color: #69f'" : ""); fprintf (output_file, "
"); fprintf (output_file, "

Simple %s to %s

", source->instance.name, destination->instance.name); @@ -138,6 +173,8 @@ table_destination_each (Babl *babl, static int source_no = 0; + + static int table_source_each (Babl *babl, void *userdata) @@ -264,6 +301,7 @@ babl_fish_stats (FILE *file) { output_file = file; + table_sum_processings_calc (); fprintf (output_file, "\n" "\n" -- 2.30.2